package com.example.oss.controller;


import com.example.oss.annotation.OperationLog;
import com.example.oss.annotation.RefreshLimit;
import com.example.oss.entity.Student;
import com.example.oss.util.UserContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class IndexController {

    @OperationLog("进入首页")
    //4秒内最多点击一次
    @RefreshLimit(second = 4, maxCount = 1)
    @GetMapping({"/index", "/"})
    public String toIndex(Model model) {
        Student student = UserContextHolder.getUser();
        model.addAttribute("loginUser", student);
        return "index";
    }

    @OperationLog("跳转服务器错误页面")
    @GetMapping("/500")
    public String error() {
        return "error/500";
    }

    @OperationLog("跳转权限不足页面")
    @GetMapping("/403")
    public String denied() {
        return "error/403";
    }

    @OperationLog("跳转限流页面")
    @GetMapping("/401")
    public String accessLimit() {
        return "error/401";
    }

    @OperationLog("跳转防刷页面")
    @GetMapping("/400")
    public String refreshLimit() {
        return "error/400";
    }



}
